﻿namespace Max.PH5_2103A.Shopping.Frame.DTO
{
    /// <summary>
    /// 服务器给请求的响应结果DTO
    /// </summary>
    public class ResponseResultDto
    {
        private string message;

        /// <summary>
        /// 状态码
        /// </summary>
        public ResponseStateCode Code { get; set; } = ResponseStateCode.Success;

        /*
         * 如果没有手动指定message的值，那么则取code的名称
         * **/
        /// <summary>
        /// 状态码对应的提示信息
        /// </summary>
        public string Message {
            get {
                if(string.IsNullOrEmpty(message))
                {
                    message = this.Code.ToString();
                }

                return message;
            } 
            set => message = value; 
        }

        /// <summary>
        /// 具体的数据
        /// </summary>
        public dynamic Data { get; set; }
    }

    /// <summary>
    /// 服务器响应状态码
    /// </summary>
    public enum ResponseStateCode
    {
        Success = 200,
        Failed = 500,
        Err_Params = -600,//参数错误

        #region 商品相关

        Err_Stock = -601, //库存不足

        #endregion
    }
}